#-----------------------------------
# Name: Will Anderson
# Project Madlibs.py
# Period: 1
# Start Date: 9/18/2013
# Last Revision Date: 9/18/2013
# Version: 1.0.0
#----------------------------
import os

swearList = ["dumb",
			 "stupid",
			 "retard",
			 'lmfao',
			 'lmafo',]


bgColor = '0'
txtColor = 'F'
os.system("color " + bgColor + txtColor)

def getMenuOption(maxOptions):
	option = ""
	goodOption = False
	while not goodOption:
		option = raw_input("\n\nEnter a number or S or Q: ")
		option = option.upper()
		if option == 'S':
			goodOption = True
		elif option == 'Q' :
			goodOption = True
		elif option == "":
			pass
		else:
			isNum = True
			for character in option:
				if character not in "0123456789":
					isNum = False
			if isNum:
				if int(option) <= 0:
					isNum = False
				elif int(option) > maxOptions:
					isNum = False
			if isNum:
				goodOption = True
			else:
				print "Please type a number!"
		if not goodOption:
			print "Invalid Choice, please try again. "
	return option

def menu():
	print "\n\n\n\n----------------------------------"
	print "Welcome to Madlibs"
	print "Please Select an Option:"
	print " [1] Fairy Tale"
	print ' [2] Doctor'
	print ' [3] Dentist'
	print " [S] Settings"
	print " [Q] Quit"
	print "----------------------------------"
	option = getMenuOption(3)
	return option

def getWord(prompt):
	word = ""
	goodWord = False
	while not goodWord:
		word = raw_input(prompt)
		if word.lower() not in swearList:
			goodWord = True
		else:
			print "Naughty user...please be polite!\n\n"
		if not goodWord:
			print "Please try again.\n"
	return word

def getContinent(prompt):
    continentList = [   "North America",
                        "South America",
                        "Europe",
                        "Asia",
                        "Africa",
                        'Australia',
                        "Antarctica"]
                 
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        word = word.capitalize()
        if word in continentList:
            goodWord = True
        else:
            print "That's not an continent"
        if not goodWord:
            print "Please try again."
    return word


def getState(prompt):
    statetList = [   'Alaska',
                        'Alabama',
                        'Arizona',
                        'Arkansas',
                        'California',
                        'Colorado',
                        'Connecticut',
                        'Delaware',
                        'Florida',
                        'Georgia',
                        'Hawaii',
                        'Idaho',
                        'Illinois',
                        'Indiana',
                        'Iowa',
                        'Kansas',
                        'Kentucky',
                        'Louisiana',
                        'Maine',
                        'Maryland',
                        'Massachusetts',
                        'Michigan',
                        'Minnesota',
                        'Mississippi',
                        'Missouri',
                        'Montana',
                        'Nebraska',
                        'New Hampshire',
                        'New Mexico',
                        'New Jersey',
                        'New York',
                        'Nevada',
                        'North Carolina',
                        'North Dakota',
                        'Ohio',
                        'Oklahoma',
                        'Oregon',
                        'Pennsylvania',
                        'Philadelphia',
                        'Rhode Island',
                        'South Carolina',
                        'South Dakota',
                        'Tennesee',
                        'Texas',
                        'Utah',
                        'Virginia',
                        'Washington',
                        'West Virginia',
                        'Wisconsin',
                        'Wyoming']


                        
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        word = word.capitalize()
        if word in stateList:
            goodWord = True
        else:
            print "That's not a state"
        if not goodWord:
            print "Please try again."
    return word



def getNumber(prompt, min = "", max = ""):
		num = ""
		goodNumber = False
		while not goodNumber:
			num = raw_input(prompt)
			isNum = True
			for digit in num:
				if digit not in ".0123456789":
					isNum = False
			if isNum:
				if min != "":
					if float(num) < min:
						isNum = False
				if max != "":
					if float(num) > max:
						isNum = False
			if isNum:
				goodNumber = True
			else:
				print "Please enter a valid number"
		return num

def getColor(prompt):
	colors = ["black",
                  "blue",
		  "green",
		  "aqua",
		  "red",
		  "purple",
		  'yellow',
		  'white',
		  'gray',
		  'light blue',
		  'light green',
		  'light aqua',
		  'light red',
		  'light purple',
		  'light yellow',
		  'bright white']
	opt = ""
	goodColor = False
	while not goodColor:
		opt = raw_input(prompt)
		if opt.lower() in colors:
			goodColor = True
	if opt == "black":
		color = '0'
	elif opt == 'blue':
		color = '1'
	elif opt == 'green':
		color = '2'
	elif opt == 'aqua':
		color = '3'
	elif opt == 'red':
		color = '4'
	elif opt == 'purple':
		color = '5'
	elif opt == 'yellow':
		color = '6'
	elif opt == 'white':
		color = '7'
	elif opt == 'gray':
		color = '8'
	elif opt == 'light blue':
		color = '9'
	elif opt == 'light green':
		color = 'A'
	elif opt == 'light aqua':
		color = 'B'
	elif opt == 'light red':
		color = 'C'
	elif opt == 'light purple':
		color = 'D'
	elif opt == 'light yellow':
		color = 'E'
	elif opt == 'bright white':
		color = 'F'
	
	return color

def story1():
        bgColor = '1'
        txtColor = 'E'
        os.system("color " + bgColor + txtColor)
	print "\n\n----------------------------------"
	mythicalbeast = getWord("Enter a mythical creature: ")
	print "----------------------------------"
	travel = getWord("Enter another name for travel: ")
	print "----------------------------------"
	game = getWord("Enter the name of a game: ")
	print "----------------------------------"
	fun = getWord("Another term for fun: ")
	print "----------------------------------"
	name = getWord("Enter the name of a boy: ")
	print "----------------------------------"
	friend = getWord('Enter the name of your best friend: ')
	print "----------------------------------"
	town = getWord('Enter the name of a place or town: ')
	print "----------------------------------"
	villager = getWord('Enter the name of an indian tribe: ')
	print "----------------------------------"
	people = getWord('Townspeople or Villagers: ')
	print "----------------------------------"
	monster = getWord('Enter the name of a monster: ')
	print "----------------------------------"
	pcolor = getWord('Enter the name of your favorite color: ')
	print "----------------------------------"
	pcolor2 = getWord('Enter the name of your second favorite color: ')
	print "----------------------------------"
	size = getWord('Size of an object: ')
	print "----------------------------------"
	pot = getWord('Pot or pan: ')
	print "----------------------------------"
	
	story = '\n\n\n\n\n\n\n\n\n--------------------------------------------------------------------------------'
	story += "Once upon a time, in the land where "
	story += mythicalbeast + "s "
	story += travel + " the land, there was a boy named "
	story += name + ".\n "
	story += '\n--------------------------------------------------------------------------------'
	story += "Him and his friends were playing a game of "
	story += game + ", "
	story += "it was "
	story += fun + '.\n'
	story += '\n--------------------------------------------------------------------------------'
	story += 'He enjoyed doing this game every day. '
	story += '\n--------------------------------------------------------------------------------'
	story += '\nHe lived in the town of ' + town + '. '
	story += '\n--------------------------------------------------------------------------------'
	story += '\nOne day, in ' + town + ', ' 
	story += 'a(n) ' + villager + ' came screaming through the town. '
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThe ' + people + ' were all worried now, when ' + name + ' asked what had happened.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThe ' + villager + ' replied, a ' + monster + ' is after us a ' + monster + ' is after us!'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThis scene caused even more ' + people + ' to be worried.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\n' + name + ' said that he would look into this.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nHe then set out with his best friend ' + friend +' , into the forest with which the direction of the ' + villager + ' came running out of.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\n' + name + ' and his friend ' + friend + ' traveled down path after path, clearing after clearing, until they came to a building they have never seen before.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nA mystic aura was surrounding it, for they saw a ' + pcolor + ', ' + pcolor2 + ' mist surrounding it.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThey then saw a creature peep out of one of the windows in the building.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThe creature then screams out at them and says, You can only come in if you leave your weapons behind.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThey go inside the building and they see an old hermit making some stew in a ' + size + pot + '. '
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThey ask the hermit what had happened and if she saw a creature in the woods. '
	story += '\n--------------------------------------------------------------------------------'
	story += '\nShe replied, was it that ' + villager + ' that was running into the camp screaming?'
	story += '\n--------------------------------------------------------------------------------'
	story += '\n' + name + ' said yes.' 
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThe hermit said that the creature was herself.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThey talk a little bit more of what she was doing in the woods and what the building was for.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\n' + name + ' and his friend ' + friend + ' headed back to the village and spot the ' + villager + ' and told him what had happened.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nThey take him back to the site and he saw the hermit.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nHe apologized and everyone now felt relieved that there was no monster, after all.'
	story += '\n--------------------------------------------------------------------------------'
	story += '\nTHE END'	
	story += '\n--------------------------------------------------------------------------------'
	
	
	story += "\n\n\n\n\n\n\n\n"
	print story
	
def story2():
        bgColor = '8'
        txtColor = 'B'
        os.system("color " + bgColor + txtColor)
	noun = getWord ("Enter an animal: ")
	noun2 = getWord ("Enter a name : ")
	noun3 = getWord ("Enter a place: ")
	noun4 = getWord ("Enter a body part: ")
	verb = getWord ("Enter an action word: ")
	verb2 = getWord ("Enter a second action word: ")
	adjective = getWord ("Enter an adjective: ")
	adjective2 = getWord ("Enter a second adjective: ")
	adjective3 = getWord ("Enter a third adjective: ")
	adverb = getWord ("Enter an adverb: ")
	adverb2 = getWord ("Enter a second adverb: ")

	story = 'There once was a ' + adverb + adjective + noun + ' named ' + noun2 + ' . '
	story += '\n' + noun2 + ' was ' + adverb2 + adjective2 + ' who would always ' + verb + ' and ' + verb2 + ' .'
	story += '\nSo, ' + noun2 + ' went to ' + noun3 + ' to see the Doctor who said You are very ' + adjective3 + ' and you need extensive treatment for your ' + noun4 + ' .'

	print story2

def story3():
        bgColor = '4'
        txtColor = 'A'
        os.system("color " + bgColor + txtColor)
	noun = getWord ("Enter an animal: ")
	noun2 = getWord ("Enter a name : ")
	noun3 = getWord ("Enter a place: ")
	noun4 = getWord ("Enter a body part: ")
	verb = getWord ("Enter an action word: ")
	verb2 = getWord ("Enter a second action word: ")
	adjective = getWord ("Enter an adjective: ")
	adjective2 = getWord ("Enter a second adjective: ")
	adjective3 = getWord ("Enter a third adjective: ")
	adverb = getWord ("Enter an adverb: ")
	adverb2 = getWord ("Enter a second adverb: ")

	story = 'Once upon a time ' + adverb + adjective + noun + ' who goes by the name of ' + noun2 + ' . '
	story += '\n' + noun2 + ' was ' + adverb2 + adjective2 + ' who would always ' + verb + ' and ' + verb2 + ' .'
	story += '\nSo, ' + noun2 + ' went to ' + noun3 + ' to see a Dentist who said You are very ' + adjective3 + ' and you need an emergency filling for your ' + noun4 + ' .'

	print story3
	
def settings():
	txtColor = getColor('Enter Text Color.\nColors are:\n----------------------------------\nblack\n----------------------------------\nblue\n----------------------------------\ngreen\n----------------------------------\naqua\n----------------------------------\nred\n----------------------------------\npurple\n----------------------------------\nyellow\n----------------------------------\nwhite\n----------------------------------\ngray\n----------------------------------\nlight blue\n----------------------------------\nlight green\n----------------------------------\nlight aqua\n----------------------------------\nlight red\n----------------------------------\nlight purple\n----------------------------------\nlight yellow\n----------------------------------\nbright white\n----------------------------------\nTEXT COLOR IS: ')
	bgColor = getColor('\nEnter Backgound Color.\nColors are:\n----------------------------------\nblack\n----------------------------------\nblue\n----------------------------------\ngreen\n----------------------------------\naqua\n----------------------------------\nred\n----------------------------------\npurple\n----------------------------------\nyellow\n----------------------------------\nwhite\n----------------------------------\ngray\n----------------------------------\nlight blue\n----------------------------------\nlight green\n----------------------------------\nlight aqua\n----------------------------------\nlight red\n----------------------------------\nlight purple\n----------------------------------\nlight yellow\n----------------------------------\nbright white\n----------------------------------\nBACKGROUND COLOR IS: ')
	if txtColor != bgColor:
		os.system("color " + bgColor + txtColor)
	
def run():
	choice = ""
	while choice != 'Q':
		choice = menu()
		if choice == '1':
			story1()
		elif choice == '2':
			story2()
		elif choice == '3':
			story3()
		elif choice == 'S':
			settings()
		elif choice == 'Q':
			print " Goodbye"
			os.system("color " + bgColor + txtColor)
			raw_input("Press enter to exit")
		else:
			print "Something terrible has happened...go yell at the programmer"
	
run()
